﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace AffinityORMLibrary.DataLayer.Utility
{
    class SQLComparer
    {
        public static string SelectionCriteriaComparerStringValue(SelectionCriteriaComparer c)
        {
            string result = string.Empty;

            switch (c)
            {
                case SelectionCriteriaComparer.Equals:
                    result = "=";
                    break;
                case SelectionCriteriaComparer.Greater:
                    result = ">";
                    break;
                case SelectionCriteriaComparer.GreaterAndEqual:
                    result = ">=";
                    break;
                case SelectionCriteriaComparer.Less:
                    result = "<";
                    break;
                case SelectionCriteriaComparer.LessAndEqual:
                    result = "<=";
                    break;
                default:
                    break;
            }

            return result;
        }
    }

    public enum SelectionCriteriaComparer
    {
        Equals, Greater, Less, GreaterAndEqual, LessAndEqual
    }

    public class SelectionComparerRow
    {
        private object _obj;
        private SelectionCriteriaComparer _comparer;
        private PropertyInfo _property;

        public object Value
        {
            get { return _obj; }
            set { _obj = value; }
        }

        public SelectionCriteriaComparer Comparer
        {
            get { return _comparer; }
            set { _comparer = value; }
        }

        public PropertyInfo Property
        {
            get { return _property; }
            set { _property = value; }
        }

        public SelectionComparerRow(PropertyInfo property, object val, SelectionCriteriaComparer comparer)
        {
            _property = property;
            _obj = val;
            _comparer = comparer;
        }
    }
}
